<template>
  <div class="dashboard-container">
    <div class="dashboard-text">name: {{ name }}</div>
    <svg>
      <use xlink:href="#icon-dashboard" />
    </svg>
    <svg-icon icon-class="dashboard" />
    <!--
      before-upload:上传前执行的方法 校验上传的文件 格式、大小
      on-sucess:上传成功后执行的方法 拿到上传表中的数据

     -->
    <UploadExcel :on-success="handleSucess" :before-upload="beforeUpload" />
    <ImageUpload :limit="2" />
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  name: 'Dashboard',
  computed: {
    ...mapGetters([
      'name'
    ])
  },
  methods: {
    // 上传前的校验
    beforeUpload(file) {
      console.log(file)
      return true
    },
    // 上传成功后 拿到文件中的数据
    handleSucess({ results, header }) {
      console.log(results)
      console.log(header)
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
